package com.yanqu.road.server.logic.recharge;

import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.config.goods.MallInfo;
import com.yanqu.road.entity.enums.eLogMoneyType;
import com.yanqu.road.entity.log.LogDunHuangShiKuBuyRmbMall;
import com.yanqu.road.entity.recharge.RechargeOrder;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.dunhuangshiku.DunHuangShiKuModule;
import com.yanqu.road.server.gameplayer.module.player.CurrencyModule;
import com.yanqu.road.server.manger.log.AutoLogMgr;
import com.yanqu.road.utils.property.PropertyHelper;

/**
 * 敦煌石窟
 */
public class DunHuangShiKuRecharge extends BaseRecharge {

    public DunHuangShiKuRecharge(GamePlayer player, MallInfo mallInfo, ActivityInfo activityInfo) {
        super(player, mallInfo, activityInfo);
    }

    @Override
    protected boolean isRepeatedBuy(String orderNo) {
        return !player.getModule(DunHuangShiKuModule.class).canChargeSucceed(mallInfo.getMallId());
    }

    @Override
    protected void repeatedBuyLogic() {

    }

    @Override
    protected String addMall(String orderNo, RechargeOrder rechargeOrder) {
        String rewardStr = "";
        DunHuangShiKuModule dunHuangShiKuModule = player.getModule(DunHuangShiKuModule.class);
        if (dunHuangShiKuModule.canChargeSucceed(mallInfo.getMallId())) {
            // 加日志
            AutoLogMgr.add(new LogDunHuangShiKuBuyRmbMall(mallInfo.getActivityId(), player.getUserId(), dunHuangShiKuModule.teamId, dunHuangShiKuModule.regionId, mallInfo.getMallId(), mallInfo.getReward()));
            player.getModule(CurrencyModule.class).addCurrency(PropertyHelper.parseStringToProperty(mallInfo.getReward()),
                    eLogMoneyType.Recharge, eLogMoneyType.ReChargeGet);
            logger.info("订单: {}, 购买 敦煌石窟礼包 商品: {}", orderNo, mallInfo.getMallId());
            dunHuangShiKuModule.shopBuy(mallInfo.getMallId());
            rewardStr = mallInfo.getReward();
        }
        return rewardStr;
    }


}
